package mycoffee.order.activity;

import mycoffee.order.R;
import android.content.Intent;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

/**
 * 
 * @author Tuong
 * 
 */
public class LoginActivity extends BaseActivity {
	private EditText mEtUserName;
	private EditText mEtPassWord;
	private TextView mTvError;
	private TextView mTvForGotPassword;
	private TextView mTvMessageForgotPassword;

	private final static String USER_NAME = "admin";
	private final static String PASS_WORD = "123456";

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.login);

		mEtUserName = (EditText) findViewById(R.id.login_tv_username);
		mEtPassWord = (EditText) findViewById(R.id.login_tv_password);
		setTvError((TextView) findViewById(R.id.login_tv_error));
		mTvForGotPassword = (TextView) findViewById(R.id.login_tv_forgotpassword);
		mTvMessageForgotPassword = (TextView) findViewById(R.id.login_tv_messageforgotpassword);
		
		Button btLogin = (Button) findViewById(R.id.login_bt_OK);
		btLogin.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				if (TextUtils.equals(USER_NAME, mEtUserName.getText()
						.toString())
						&& TextUtils.equals(PASS_WORD, mEtPassWord.getText()
								.toString())) {
					// start MainActivity.
					Intent intent = new Intent(getApplicationContext(),
							MainActivity.class);
					startActivity(intent);
					finish();
				} // else {
					// mTvError.setVisibility(View.VISIBLE);
				// }
			}
		});
		mTvForGotPassword.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				mTvMessageForgotPassword.setVisibility(View.VISIBLE);

			}
		});
	}

	public TextView getTvError() {
		return mTvError;
	}

	public void setTvError(TextView mTvError) {
		this.mTvError = mTvError;
	}
}
